#ifndef PROGRAMMEDIALOG_H_
#define PROGRAMMEDIALOG_H_

#include <qstring.h>

#include <mythtv/mythdialogs.h>

#include <memory>

class Metadata;
class ProgrammeList;
class ParentalLevel;

class ProgrammeDialog : public MythDialog
{
    Q_OBJECT

  public:
    enum DialogType { DLG_GALLERY = 0x2, DLG_TREE = 0x4,
                      dtLast };

    static bool IsValidDialogType(int num);

    ProgrammeDialog(DialogType ltype, MythMainWindow *lparent,
                const QString &lwinName, const QString &lname,
                ProgrammeList *programme_list);

    virtual void playProgramme(Metadata *someItem);

    GenericTree *getProgrammeTreeRoot(void);

    void setFlatList(bool toWhat) { isFlatList = toWhat;}

    int programmeExitType() { return m_exit_type; }

  protected slots:
    void slotDoCancel();
    void slotProgrammeTree();
    void slotProgrammeGallery();
    void slotViewPlot();
    void slotDoFilter();
    void exitWin();
    virtual void slotParentalLevelChanged();
    virtual void slotWatchProgramme();

  protected:
    virtual ~ProgrammeDialog(); // use deleteLater() instead for thread safety
    virtual void updateBackground(void);
    virtual void parseContainer(QDomElement&) = 0;
    virtual void loadWindow(QDomElement &element);
    virtual void fetchProgrammes();
    virtual void setParentalLevel(const ParentalLevel &which_level);
    void shiftParental(int amount);
    bool createPopup();
    void cancelPopup(void);
    void doMenu(bool info);
    QButton *AddPopupViews();

    QPixmap myBackground;
    std::auto_ptr<ParentalLevel> currentParentalLevel;
    bool isFlatList;
    Metadata* curitem;
    MythPopupBox* popup;
    bool expectingPopup;
    QRect fullRect;
    int m_type;

    bool allowPaint;

    std::auto_ptr<XMLParse> theme;
    QDomElement xmldata;

    ProgrammeList *m_programme_list;
    GenericTree *programme_tree_root;

  private:
    void jumpTo(const QString &location);
    void setExitType(int exit_type) { m_exit_type = exit_type; }

  private:
    int m_exit_type;
};

#endif
